<template>
	<view class="couponBox" :class="{on:active}">
		<view class="leftBox" v-if="dataItem.limits">
			<view class="num">{{dataItem.limits}}</view>
			<view class="text">折扣卷(元)</view>
		</view>
		<view class="centerBox">
			<view class="couponName">
				<view class=" u-line-2">
					{{dataItem[nameKey]}}
				</view>
			</view>
			<view class="couponEndTime">有效期：{{dataItem.effectiveFinishTime||dataItem.expirationTime}}</view>
		</view>
		<view class="rightBox" v-if="rightBtn">
			<!-- <view class="couponStatusText">已使用</view> -->
			<view class="btn" @click="btnClick">{{btnText}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "couponItem",
		props: {
			active: {
				type: Boolean,
				default: false
			},
			rightBtn: {
				type: Boolean,
				default: true
			},
			nameKey: {
				type: String,
				default: 'comuponName'
			},
			btnText: {
				type: String,
				default: '领取'
			},
			dataItem: {
				type: Object,
				default: () => {}
			}
		},
		data() {
			return {

			};
		},
		methods: {
			btnClick() {
				this.$emit('btnClick')
			},
		}

	}
</script>

<style lang="scss" scoped>
	.couponBox {
		display: flex;
		align-items: center;
		// height: 364rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		margin-bottom: 30rpx;
		padding: 30rpx;
		border: 1rpx solid #FFFFFF;
		box-sizing: border-box;

		&.on {
			border: 1rpx solid #0138D2;
		}

		.leftBox {
			text-align: center;
			margin-right: 30rpx;
			flex-shrink: 0;

			.num {
				font-size: 48rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				color: #0138D2;
				margin-bottom: 10rpx;
			}

			.text {
				font-size: 20rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				color: #0138D2;
			}
		}

		.centerBox {
			width: 100%;

			.couponName {
				min-height: 84rpx;
				font-size: 32rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				color: #000000;
			}

			.couponEndTime {
				font-size: 28rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				color: #666666;
			}
		}

		.rightBox {
			flex-shrink: 0;
		}

		.couponStatusText {
			font-size: 28rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			color: #979797;
		}

		.btn {
			display: flex;
			justify-content: center;
			align-items: center;
			width: 180rpx;
			height: 76rpx;
			background: linear-gradient(90deg, #5F96E8 0%, #1977E1 100%);
			border-radius: 40rpx;
			font-size: 28rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			color: #FFFFFF;
		}
	}
</style>